Skip to content

Conversation

@FilipPyrek
Copy link
Member

@FilipPyrek FilipPyrek commented Oct 13, 2025

  • Installs pandas and numpy to the venv.
  • These dependencies are required for the dataframe code
  • Also refactored the code to support adding other dependencies later.

Summary by CodeRabbit

  • Chores
    • Installer now sets up all required runtime dependencies in one step (including kernel support and common data libraries), reducing post-install missing package issues.
    • Updated installation messages to clearly indicate multiple dependencies are being installed, providing better progress visibility.
    • Preserves existing virtual environment creation and pip upgrade flow, ensuring a consistent setup experience.

@linear
Copy link

linear bot commented Oct 13, 2025

GRN-4914 Include pandas and numpy in the Deepnote kernel

It's required for our dataframe code.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 13, 2025

📝 Walkthrough

Walkthrough

The installer now defines a dependencies array containing deepnote-toolkit[server] (via URL), ipykernel, pandas, and numpy. It logs and installs all dependencies using a single pip install invocation that spreads the array. User-facing messages were updated to reference multiple runtime dependencies. The rest of the flow remains unchanged: create a virtual environment, upgrade pip, then perform kernel-spec installation.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant VSCode as VS Code Extension
  participant Installer as DeepnoteToolkitInstaller
  participant Venv as Python venv
  participant Pip

  User->>VSCode: Trigger toolkit setup
  VSCode->>Installer: start()
  Installer->>Installer: Create venv (unchanged)
  Installer->>Pip: python -m pip install --upgrade pip (unchanged)
  Note over Installer,Pip: Install dependencies via single command (new)
  Installer->>Pip: pip install [deepnote-toolkit[server]@URL, ipykernel, pandas, numpy]
  Pip-->>Installer: Installed packages
  Installer->>Installer: Install kernelspec (unchanged)
  Installer-->>VSCode: Done
Loading

Possibly related PRs

Suggested reviewers

  • m1so

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the core feature—adding pandas and numpy support—directly matching the changes to the installer’s dependency list and making the PR’s purpose clear at a glance.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70%. Comparing base (f59e68f) to head (84586ce).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main     #43   +/-   ##
=====================================
  Coverage     70%     70%           
=====================================
  Files        512     512           
  Lines      37506   37506           
  Branches    4811    4811           
=====================================
  Hits       26473   26473           
  Misses      9441    9441           
  Partials    1592    1592           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (1)

211-254: Verify pandas and numpy installation.

Only deepnote-toolkit is verified post-install. pandas/numpy installation could silently fail, breaking dataframe functionality.

Add verification for all dependencies:

 // Verify installation
-if (await this.isToolkitInstalled(venvInterpreter)) {
+if (await this.areAllDependenciesInstalled(venvInterpreter)) {
     logger.info('deepnote-toolkit installed successfully in venv');

Then add a new method:

private async areAllDependenciesInstalled(interpreter: PythonEnvironment): Promise<boolean> {
    const requiredPackages = ['deepnote_toolkit', 'pandas', 'numpy', 'ipykernel'];
    try {
        const processService = await this.processServiceFactory.create(undefined);
        for (const pkg of requiredPackages) {
            const result = await processService.exec(interpreter.uri.fsPath, [
                '-c',
                `import ${pkg}; print('installed')`
            ]);
            if (!result.stdout.toLowerCase().includes('installed')) {
                logger.error(`Required package ${pkg} not found`);
                return false;
            }
        }
        return true;
    } catch (ex) {
        logger.debug(`Dependency check failed: ${ex}`);
        return false;
    }
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f59e68f and 84586ce.

📒 Files selected for processing (1)
  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.node.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use *.node.ts for Desktop-specific implementations that require full file system access and Python environments

Files:

  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Inject interfaces, not concrete classes
Avoid circular dependencies
Use l10n.t() for user-facing strings
Use typed error classes from src/platform/errors/ when throwing or handling errors
Use the ILogger service instead of console.log
Preserve error details while scrubbing PII in messages and telemetry
Include the Microsoft copyright header in source files
Prefer async/await and handle cancellation with CancellationToken

**/*.{ts,tsx}: Order class members (methods, fields, properties) first by accessibility (public/protected/private) and then alphabetically
Do not add the Microsoft copyright header to new files
Use Uri.joinPath() to construct file paths instead of manual string concatenation
Add a blank line after groups of const declarations and before return statements for readability
Separate third-party imports from local file imports

Files:

  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts
src/kernels/**/*.ts

📄 CodeRabbit inference engine (.github/instructions/kernel.instructions.md)

src/kernels/**/*.ts: Use event-driven updates (EventEmitter) for state changes
Monitor and dispose pending promises to prevent leaks during teardown
Use WeakRef/weak references for notebook/object backreferences to avoid memory leaks
Respect CancellationToken in all async operations

Files:

  • src/kernels/deepnote/deepnoteToolkitInstaller.node.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: hc2p
PR: deepnote/environments#62
File: gpu/Dockerfile:0-0
Timestamp: 2025-09-25T13:16:13.796Z
Learning: In Deepnote's Docker environment setup, packages installed in the underlying Docker image should be in system site packages, not in virtual environments. Server/kernels are launched in a virtual environment created by the installer, which creates a pth file where system site packages are appended first, giving them higher precedence and making them first in the search path. This is expected behavior for the deepnote-toolkit setup.
🧬 Code graph analysis (1)
src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (1)
src/kernels/deepnote/types.ts (1)
  • DEEPNOTE_TOOLKIT_WHEEL_URL (158-158)
🔇 Additional comments (2)
src/kernels/deepnote/deepnoteToolkitInstaller.node.ts (2)

193-193: LGTM!

Logging all dependencies clearly.


196-200: LGTM!

Spread operator usage is clean and extensible.

Comment on lines +184 to +190
// Define dependencies to install
const dependencies = [
`deepnote-toolkit[server] @ ${DEEPNOTE_TOOLKIT_WHEEL_URL}`,
'ipykernel',
'pandas',
'numpy'
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Pin pandas and numpy versions for reproducible builds.

Unversioned dependencies create non-reproducible builds and risk compatibility issues from future major releases.

Apply this diff to pin versions:

 const dependencies = [
     `deepnote-toolkit[server] @ ${DEEPNOTE_TOOLKIT_WHEEL_URL}`,
     'ipykernel',
-    'pandas',
-    'numpy'
+    'pandas>=2.0.0,<3.0.0',
+    'numpy>=1.24.0,<2.0.0'
 ];

Verify current production versions:


🏁 Script executed:

#!/bin/bash
# Check latest stable versions of pandas and numpy
pip index versions pandas | head -5
pip index versions numpy | head -5

Length of output: 2001


Pin pandas and numpy versions, use l10n.t(), and verify all dependencies

  • Replace unversioned pandas/numpy with 'pandas>=2.3.3,<3.0.0' and 'numpy>=2.3.3,<3.0.0' in the dependencies array
  • Wrap the user-facing output in l10n.t() (currently at line 194)
  • Extend post-installation checks (isToolkitInstalled) to verify that pandas and numpy were installed
 const dependencies = [
     `deepnote-toolkit[server] @ ${DEEPNOTE_TOOLKIT_WHEEL_URL}`,
     'ipykernel',
-    'pandas',
-    'numpy'
+    'pandas>=2.3.3,<3.0.0',
+    'numpy>=2.3.3,<3.0.0'
 ];
🤖 Prompt for AI Agents
In src/kernels/deepnote/deepnoteToolkitInstaller.node.ts around lines 184 to
190, update the dependencies array to use pinned versions for pandas and numpy
('pandas>=2.3.3,<3.0.0' and 'numpy>=2.3.3,<3.0.0') instead of unversioned names;
wrap the user-facing output call at ~line 194 in l10n.t(...) so messages are
localized; and extend the isToolkitInstalled post-installation checks to also
verify that pandas and numpy are present (e.g., by checking importability or pip
list) and return false if either is missing so the installer can retry or
surface an error.


// Install all dependencies in venv
logger.info(`Installing dependencies in venv: ${dependencies.join(', ')}`);
this.outputChannel.appendLine('Installing deepnote-toolkit, ipykernel, and other runtime dependencies...');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use l10n.t() for user-facing strings and improve clarity.

The message explicitly names two packages but vaguely refers to others. Also, coding guidelines require l10n.t() for user-facing strings.

Apply this diff:

-this.outputChannel.appendLine('Installing deepnote-toolkit, ipykernel, and other runtime dependencies...');
+this.outputChannel.appendLine(l10n.t('Installing runtime dependencies (deepnote-toolkit, ipykernel, pandas, numpy)...'));

Note: You'll need to import l10n from vscode at the top of the file.

As per coding guidelines.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/kernels/deepnote/deepnoteToolkitInstaller.node.ts around line 194, the
user-facing message is hard-coded and names two packages while saying "and other
runtime dependencies"; import l10n from 'vscode' at the top of the file and
replace the hard-coded string with a localized message using l10n.t(), e.g. use
l10n.t("Installing runtime dependencies (including deepnote-toolkit and
ipykernel)...") so the message is clearer and localized.

Copy link
Member

@Artmann Artmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great :) The code rabbit suggestions looks good as well :)

@FilipPyrek
Copy link
Member Author

We found out that toolkit brings both pandas and numpy, so this task was just a false positive alert.

@FilipPyrek FilipPyrek closed this Oct 15, 2025
@FilipPyrek FilipPyrek deleted the fpyrek/grn-4914-include-pandas-and-numpy-in-the-deepnote-kernel branch October 15, 2025 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants